<?php
class Crm extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		$this->load->model('crm_model');
		$this->load->helper(array('form', 'url'));
	}

	public function view($page = 'crm')
	{

		if ( ! file_exists('application/views/crm/'.$page.'.php'))
		{
			// 页面不存在
			show_404();
		}
		
		$email = '';
		$password = '';
		$data = array();
		if(is_array($_POST)&&count($_POST)>0)//先判断是否通过get传值了
	    {
	        if(isset($_POST["inputEmail"]))//是否存在"id"的参数
	        {
	            $email=$_POST["inputEmail"];//存在
	        }
	   		 if(isset($_POST["inputPassword"]))//是否存在"id"的参数
	        {
	            $password=$_POST["inputPassword"];//存在
	        }
	    }
	    $result = $this->crm_model->get_user($email, $password);
	    if ($result)
	    {
	    	$data['user'] = $result;
	    }
	    $company_info = $this->crm_model->get_company_info();
	    $data['company_info'] = $company_info;
	    $data['error'] = '';
			
			$this->load->view('crm/crm', $data);
	}
	
	
}